package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IUnusualFeedBackForDamageView;
import com.cloudsigns.factorymanager2.engineering.model.IUnusualFeedBackForDamageModel;
import com.cloudsigns.factorymanager2.engineering.model.UnusualFeedBackForDamageModel;

/**
 * Created by tony on 2018/4/20.
 */

public class UnusualFeedBackForDamagePrsenter {
    private IUnusualFeedBackForDamageView view;
    private IUnusualFeedBackForDamageModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public UnusualFeedBackForDamagePrsenter(IUnusualFeedBackForDamageView view) {
        this.view = view;
        this.model = new UnusualFeedBackForDamageModel();
    }

    public void submitUnusualFeedBackForDamage() {


        model.submitUnusualFeedBackForDamage(view.getAdvice(), view.getDamageNumber(), view.getDamageProduct(), view.getId(), view.getImgUrlList(), view.getItemId(), view.getType(), view.getUnusualDays(), new UnusualFeedBackForDamageModel.OnUnusualFeedBackFoLogisticsLeakageListener() {

            @Override
            public void submitUnusualFeedBackForDamageSunccessed() {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.submitUnusualFeedBackForDamageSunccessed();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void submitUnusualFeedBackForDamageFailed(final String desc) {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.submitUnusualFeedBackForDamageFailed(desc);
                        view.hideLoading();
                    }
                });
            }
        });
    }

}
